package core.testes.lexical;

import java.io.File;
import java.io.FileReader;

import core.codeGeneration.CodeGenerator;
import core.error.ErrorHandler;
import core.lexical.LexicalAnalyser;
import core.syntatic.SyntaticAnalyser;
import junit.framework.TestCase;

/**
 * It tests the string syxntax.
 * @author Diego
 *
 */
public class StringNotClosedTest extends TestCase {
	private SyntaticAnalyser parser;

	@Override
	protected void setUp() throws Exception {
		String fileName = "examples\\stringNotClosedTest.ford";
		
		FileReader source = new FileReader( new File( fileName ) );
		
		 parser = new SyntaticAnalyser(	new LexicalAnalyser( source, new ErrorHandler() ) );
		 CodeGenerator.getInstace().init(fileName.substring(9, fileName.length() - 5));
	}
	
	public void testMissingOperator(){
		try {
			parser.analyseIt();
			fail("Exception expected.");
		} catch (RuntimeException e) {
			assertEquals(e.getMessage(), "String literal is not properly closed by a double-quote.");
		}
	}
}
